package com.test.service.impl;

import com.test.mapper.DinnerTableMapper;
import com.test.pojo.DinnerTable;
import com.test.service.DinnerTableService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DinnerTableServiceImpl implements DinnerTableService {
    @Resource
    private DinnerTableMapper dinnerTableMapper;

    @Override
    public List<DinnerTable> getAllDinnerTable() {
        return dinnerTableMapper.getAllDinnerTable();
    }

    @Override
    public int updateDinnerTable(DinnerTable dinnerTable) {
        return dinnerTableMapper.updateDinnerTable(dinnerTable);
    }

    @Override
    public int deleteDinnerTable(int tableId) {
        int num = 0;
        try {
            num = dinnerTableMapper.deleteDinnerTable(tableId);
        }catch (Exception e){
            // 数据库异常
            num = -1;
        }
        return num;
    }

    @Override
    public int addDinnerTable(DinnerTable dinnerTable) {
        return dinnerTableMapper.addDinnerTable(dinnerTable);
    }

    @Override
    public List<DinnerTable> serachDinnerTable(String tableName) {
        return dinnerTableMapper.serachDinnerTable(tableName);
    }

//    @Override
//    public DinnerTable getFoodTypeByID(int typeId) {
//        return foodTypeMapper.getFoodTypeByID(typeId);
//    }

//    @Override
//    public int findNoUseTable() {
//        return dinnerTableMapper.findByStatus(tableStatus);
//    }

    @Override
    public DinnerTable findById(int tableId) {
        return dinnerTableMapper.findById(tableId);
    }

}
